@echo off
echo Compiling the project...

REM 创建输出目录
if not exist bin (
    mkdir bin
)

REM 编译所有源文件，并包含lib目录中的库
javac -encoding UTF-8 -cp "lib/*" -d bin ^
    src/Main/Main.java ^
    src/LunaServer/config/*.java ^
    src/LunaServer/core/*.java ^
    src/LunaServer/email/*.java ^
    src/LunaServer/gui/*.java ^
    src/LunaServer/logging/*.java ^
    src/LunaServer/routing/*.java ^
    src/LunaServer/user/*.java ^
    src/LunaServer/util/*.java

if %ERRORLEVEL% EQU 0 (
    echo Compilation successful!
    
    REM 复制库文件到输出目录
    if not exist bin\lib (
        mkdir bin\lib
    )
    copy lib\*.jar bin\lib\
    
    echo Libraries copied to bin\lib
    echo Build completed successfully!
) else (
    echo Compilation failed!
    pause
    exit /b 1
)